<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" type="text/css" href="../ExtJS/resources/css/ext-all.css"/>
		<script type="text/javascript" src="../ExtJS/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="../ExtJS/ext-all.js"></script>
		<script type="text/javascript">
			Ext.onReady(function() {
				var height = window.document.body.clientHeight;
			    var width = window.document.body.clientWidth;
				
				var loginForm = new Ext.form.FormPanel({
					title: '登录',
					frame: true,
					floating: true,
					labelAlign: 'right',
					width: 300,
					height: 120,
					items: [
						 { xtype: 'textfield', name: 'userName', fieldLabel: '用户名', value:'admin', allowBlank : false, anchor : '95%'},
						 { xtype: 'textfield', inputType:'password',  name: 'password', value:'admin', fieldLabel: '密&nbsp;&nbsp;&nbsp;码', allowBlank : false, anchor : '95%'}
					],
					buttons: [
						{
							text: '登录',
							width: 70,
							handler: function() {
								if(!loginForm.getForm().isValid())
									return;

								loginForm.form.doAction('submit', {
									url: '../admin/basic/LoginAction/login.action',
									method: 'post',
									params: '',
									success: function(form, action) {
										if(action.result.result == 'success') {
											window.location.href = 'main.html';
										}
										else {
											alert('用户名或者密码错误');
											loginForm.getForm().reset();
										}
									}
								});
							}
						},
						{
							text: '重置',
							handler: function() {
								loginForm.getForm().reset();
							}
						}
					]
				});
				
				loginForm.setPosition((width - loginForm.width) /2, (height - loginForm.height) / 2);
				loginForm.render('center-div');
			});
		</script>
	</head>
	<body>
		<div id="center-div"></div>
	</body>
</html>